package com.github.common.extend.demo.config.json;

import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.github.common.extend.demo.config.BaseEnum;
import com.github.common.extend.demo.config.json.jaskson.enumerate.BaseEnumPropertyJsonSerializer;

import java.lang.annotation.*;

/**
 * 实体类属性保存的是枚举编码{@link BaseEnum#getCode()}，添加这个注解，jackson框架序列化的时候支持输出枚举描述{@link BaseEnum#getDesc()}
 * @author X1993
 * @date 2022/10/24
 * @description
 */
@Documented
@Target({ElementType.FIELD ,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
@JsonSerialize(using = BaseEnumPropertyJsonSerializer.class)
public @interface BaseEnumSerialize {

    /**
     * 枚举类，必须实现{@link BaseEnum}
     * @return
     */
    Class<? extends BaseEnum> type();

    /**
     * 输出描述的属性
     * 默认是当前属性
     * @return
     */
    String descProperty() default "";

}
